package org.qy137.controller;

import com.qy137.vo.ArticleVo;
import io.swagger.annotations.ApiOperation;
import org.qy137.service.ArticleService;
import org.qy137.utils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"article"})
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    public ArticleController() {
    }

    @ApiOperation("根据id查询文章的内容")
    @GetMapping({"getArticleByNavId/{navId}"})
    public CommonResult getArticleByNavId(@PathVariable String navId) {
        return this.articleService.getArticleByNavId(navId);
    }

    @PutMapping({"updateArticleByNavId"})
    @ApiOperation("修改文章内容")
    public CommonResult updateArticleByNavId(@RequestBody ArticleVo articleVo) {
        return this.articleService.updateArticleByNavId(articleVo);
    }
}
